﻿using System;
using System.Data.SqlClient;
using Devv.Core.UniDataTier;

namespace Yglu.BusinessLayer.Entities
{
	public class Category : BaseEntity
	{
		#region Properties

		public Int32 StoreId { get; set; }
		public String Title { get; set; }
		public Int32 Priority { get; set; }
		public Boolean MultiSelect { get; set; }
		public Boolean AllStores { get; set; }

		#endregion

		#region Constructor

		public Category()
		{
		}

		public Category(Int32 id)
		{
			Construct(DataAccess.Category_Get(id));
		}

		public Category(SqlDataReader reader)
		{
			Construct(reader);
		}

		#endregion

		#region Methods

		public override void Load(SqlDataReader reader)
		{
			Id = DataHandler.GetInt32(reader, "CategoryId");
			StoreId = DataHandler.GetInt32(reader, "StoreId", 0);
			Title = DataHandler.GetString(reader, "CategoryTitle");
			Priority = DataHandler.GetInt32(reader, "CategoryPriority");
			MultiSelect = DataHandler.GetBoolean(reader, "CategoryMultiSelect");
			AllStores = DataHandler.GetBoolean(reader, "CategoryAllStores");
			Active = DataHandler.GetBoolean(reader, "CategoryActive");
		}

		#endregion

		#region ToString

		public new String ToString()
		{
			return Title;
		}

		#endregion
	}
}